<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="metabase">
	<xsl:apply-templates select="collections" mode="metabase"/>
</xsl:template>

<xsl:template match="collections" mode="metabase">
	<h1>Коллекции элементов</h1>
	<div class="mainmenuitem">	
	<div id="objects" class="clearfix">
		<div class="sline" id="collections">
			<xsl:for-each select="item">
				<div id="collection_{id}" class="collectionitem">
					<div class="control">
						<img src="/i/icons/table_delete.png" class="controlimg" alt="Удалить" title="Удалить" onclick="mbDeleteCollection('{id}');"/>
					</div>
					<div>
						<a href="/ShowCollection/{id}/"><xsl:value-of select="title"/></a>
					</div>
					<div class="collection_name"><xsl:value-of select="dbid"/>.<xsl:value-of select="name"/></div>
				</div>
			</xsl:for-each>
		</div>
	</div>
	<div id="addform" class="addform">
		<a name="form"></a>
		<div id="addformcontrol">
			<a href="#form" onclick="mbShowAddCollectionForm();" class="addcollectionlink">Добавить коллекцию</a>
		</div>
		<div id="addformitem">
				<h3>Добавить коллекцию</h3>
				<form id="formadd" onSubmit="return false;" vmethod="online">
				<div class="formitem">
					<label for="i_name" class="fwlab">Название</label>
					<input id="i_name" type="text" name="f_name" size="16" maxlength="64" vmethod="pattern" vparam="^[a-zA-Z0-9_]+$" vnotice="Поле должно содержать только буквы и цифры!"/>					
				</div>
				<div class="formitem">
					<label for="i_title" class="fwlab">Обозначение</label>
					<input id="i_title" type="text" name="f_title" size="16" maxlength="255" vmethod="pattern" vparam="string" vnotice="Поле должно быть заполнено!"/>					
				</div>
				<div class="formitem">
					<label for="i_dbid" class="fwlab">База данных</label>
					<select id="i_dbid" name="f_dbid" size="1">
						<xsl:for-each select="../databasespool/database">
							<option value="{@id}">
								<xsl:if test="@default = 'True'">
									<xsl:attribute name="selected">selected</xsl:attribute>
								</xsl:if>
								<xsl:value-of select="."/>		
							</option>
						</xsl:for-each>
					</select>					
				</div>
				<div class="formitem">
					<label class="fwlab">Опции:</label>
					<div class="boxlist">
						<ul>
							<li>
								<input type="checkbox" name="f_properties" id="i_prop_vers" value="Versions"/>
								<label for="i_prop_vers">Версионная коллекция</label>																		
							</li>
							<li>
								<input type="checkbox" name="f_properties" id="i_prop_hierar" value="Hierarchy"/>
								<label for="i_prop_hierar">Иерархическая коллекция</label>																		
							</li>
							<li>
								<input type="checkbox" name="f_properties" id="i_prop_ord" value="Order"/>
								<label for="i_prop_ord">Упорядоченная коллекция</label>																		
							</li>
						</ul>
					</div>
				</div>
				<div class="clearfix">		
					<div class="formbutton" style="float: left;">
						<input type="button" class="addbutton" value="Добавить" onclick="mbAddCollection();"/>
					</div>
					<div class="formbutton" style="float: right;">
						<input type="button" class="cancelbutton" value="Отменить" onclick="mbCancelAddCollection();"/>
					</div>
				</div>
			</form>					
		</div>
	</div>			
	</div>		
</xsl:template>

<xsl:template match="metabase" mode="ajax">
	<strong>Коллекции</strong>: &#0160; 
		<xsl:for-each select="collections/item">
			<a href="/ShowCollection/{id}/"><xsl:value-of select="title"/></a>
			<xsl:if test="not(position()=last())">, </xsl:if>
		</xsl:for-each>
</xsl:template>


</xsl:stylesheet>
